<template>
	<view class="wrap">
		<view class="wrap-box">
			<view class="title">您要的编号已生成</view>
			<view class="givenumber" @click="copyGiveNumber()">{{giveNumbername}}</view>
		</view>
		<view class="btn-box">
			<view class="return" @click="returnClick()">返回首页</view>
		</view>
	</view>

</template>

<script>
	export default {
		data() {
			return {
				giveData: {

				},
				giveNumbername: '',
			}
		},
		mounted() {

		},
		onLoad(option) {

			//alert(option.data);
			this.giveData = JSON.parse(decodeURIComponent(option.data));
			console.log(this.giveData);
			this.giveNumbername = this.giveData.giveNumber;

		},
		methods: {
			navigateBack() {
				uni.navigateBack()
			},

			returnClick() {
				
				uni.switchTab({
				    url: '/pages/home/home',
				    success: function (e) { 
				      var page = getCurrentPages().pop();
				      console.log('page',page)
				      if (page == undefined || page == null) return;
				      page.onLoad();
				    } 
				});
				// uni.redirectTo({
				// 	url: 'pages/home/home'
				// });
				// uni.navigateTo({
				// 	url: '/pages/home/home'
				// });
			},
			copyGiveNumber() {
				uni.setClipboardData({
					data: this.givenumber.giveNumber,
					success: () => {
						uni.hideToast();
						this.$nextTick(() => {
							this.$u.toast('号码已复制');
						})
					}
				});
			}


		},
	}
</script>

<style lang="scss">
	.wrap {
		margin-left: 20rpx;
		margin-right: 20rpx;
	}

	.wrap-box {
		display: flex;
		flex-direction: column;
		align-items: center;

		.title {
			font-size: 28rpx;
			font-family: PingFang SC;
			color: #333333;
			line-height: 48rpx;
		}

		.givenumber {
			font-size: 40rpx;
			font-family: PingFang SC;
			margin-top: 10rpx;
			color: #333333;
			line-height: 48rpx;
		}
	}

	.btn-box {
		margin-top: 30rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-evenly;

		.return {
			width: 280rpx;
			height: 80rpx;
			background: #3BA2FF;
			border-radius: 40rpx;
			line-height: 80rpx;
			text-align: center;
			font-size: 32rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
		}

		.confirm {
			width: 280rpx;
			height: 80rpx;
			background: #F9A048;
			border-radius: 40rpx;
			line-height: 80rpx;
			text-align: center;
			font-size: 32rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
		}
	}

	.btn {
		margin-top: 100rpx;
		margin-left: 10%;
		margin-right: 10%;
		height: 80rpx;
		line-height: 80rpx;
		background: #3BA2FF;
		border-radius: 40px;
		text-align: center;
		font-size: 32rpx;
		font-family: PingFang SC;
		color: #FFFFFF;
	}
</style>
